• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp1
r3wp15
total:16

results window for this page: [start: 1 end: 16]

world-name: r4wp

Group: Rebol School ... REBOL School [web-public]
Endo:
26-Apr-2012
I use my own functions, returns always in ISO format, YYYY-MM-DD 
HH:NN:SS


padz: func ["Pad to right with zero." s n [integer!] /left /with 
c [char! string!]] [

    head insert/dup either left [tail form s] [form s] first form either 
    with [c] [#"0"] n - length? form s
]

format-date: func [d [date!]] [

 ajoin [d/date/year "-" padz d/date/month 2 "-" padz d/date/day 2 
 either d/time [ajoin [" " padz d/time/hour 2 ":" padz d/time/minute 
 2 ":" padz to-integer d/time/second 2]] [""]]
]

world-name: r3wp

Group: Core ... Discuss core issues [web-public]
Sunanda:
27-Feb-2006
REBOL broadly follows the ISO-8601 date format (though not with the 
strict yyyymmdd format): years are 4 digit, positive numbers only. 
ISO 8601 is not designed for acheology or astronomy.

True astronomocal julian dates of course change day at midday not 
midnight -- so be really sure you want to use them.
Gregg:
25-Oct-2008
REBOL.org has a couple ISO date formatting funcs, though I think 
a lot of us roll our own, sometimes ad hoc. It depends, too, on how 
flexible--or accepting of various inputs--you want it to be.
Gregg:
25-Oct-2008
as-utc: func [date] [
    if all [date/zone  0:00 <> date/zone] [
        date: add date negate date/zone
    ]
    date/zone: none
    if none? date/time [date/time: 0:0:0]
    date
]

to-ISO8601-date: func [
    "Converts a date! value to an ISO 8601 format string."
    date [date!] "The date to format"

    /T           {Use T to delimit time value, rather than a space}
    /no-zone     "Don't include the timezone"
    /local pad z
][
    pad: func [val /to len] [
        val: form val
        head insert/dup val #"0" ((any [len 2]) - length? val)
    ]

    rejoin [
        pad/to date/year 4 "-" pad date/month "-" pad date/day
        either T ["T"] [" "]

        either none? t: date/time ["00:00:00Z"] [   ;<< reusing 'T here!
            rejoin [

                pad t/hour ":" pad t/minute ":" pad round t/second
                either no-zone [""] [

                    either 0:00 = z: date/zone ["Z"] [  ;<< setting 'z here!
                        rejoin [
                            pick ["+" "-"] z/hour > 0
                            pad abs z/hour pad abs z/minute
                        ]
                    ]
                ]
            ]
        ]
    ]
]
Group: I'm new ... Ask any question, and a helpful person will try to answer. [web-public]
Sunanda:
17-Jul-2007
This adds leading zeroes to MM or DD -- you could use similar logic:

http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=to-iso-8601-date.r
PatrickP61:
19-Jul-2007
Hi all -- I didn't mean to cause additional entries to other libraries 
-- just tried to format it in my own routine.  But since there is 
interest, I double checked the official IBM SQL reference manual 
for timestamps.

So for the record and for your information:


Although there are many many different forms (Japanese, Europe etc), 
I only focused on two elements, the ANSI  ISO timestamp, and IBM 
SQL timestamp standard.  So in the IBM book "DB2 UDB for iSeries 
SQL Reference V5R370" under "Data Types, Datetime values, table 10 
page 70":

_________________________________________________________________________________________________

Table 10. Formats for String Representations of Timestamps
Format Name			Time Format						Example

ANSI/ISO SQL standard	TIMESTAMP ’yyyy-mm-dd hh:mm:ss.nnnnnn’	TIMESTAMP 
’1990-03-02 08:30:00.010000’

IBM SQL			’yyyy-mm-dd-hh.mm.ss.nnnnnn’			’1990-03-02-08.30.00.010000’
14–character form		’yyyymmddhhmmss’					’19900302083000’

_________________________________________________________________________________________________


For the record, I think I confused the two types.  Notice the embedded 
space between the date and time as well as : separators for ANSI/ISO, 
while the IBM SQL standard contains it all (no embedded space) and 
uses periods to separate the time elements, which I will easily fix 
in my version. -- You may wish to do the same for any new form of 
date you have.
Group: Parse ... Discussion of PARSE dialect [web-public]
Sunanda:
18-Oct-2010
Regexlib has a different ISO-8601 date matching regex:
    http://regexlib.com/REDetails.aspx?regexp_id=2092

And the ability to enter any regex and target strings to test what 
happens:
    http://regexlib.com/RETester.aspx?
BrianH:
2-Dec-2011
Here's the R2 version of TO-CSV and TO-ISO-DATE (Excel compatible):

to-iso-date: funct/with [
	"Convert a date to ISO format (Excel-compatible subset)"
	date [date!] /utc "Convert zoned time to UTC time"
] [

 if utc [date: date + date/zone date/zone: none] ; Excel doesn't support 
 the Z suffix
	either date/time [ajoin [

  p0 date/year 4 "-" p0 date/month 2 "-" p0 date/day 2 " "  ; or T

  p0 date/hour 2 ":" p0 date/minute 2 ":" p0 date/second 2  ; or offsets
	]] [ajoin [
		p0 date/year 4 "-" p0 date/month 2 "-" p0 date/day 2
	]]
] [
	p0: func [what len] [ ; Function to left-pad a value with 0
		head insert/dup what: form :what "0" len - length? what
	]
]

to-csv: funct/with [
	"Convert a block of values to a CSV-formatted line in a string."
	[catch]
	data [block!] "Block of values"
] [
	output: make block! 2 * length? data
	unless empty? data [append output format-field first+ data]

 foreach x data [append append output "," format-field get/any 'x]
	to-string output
] [
	format-field: func [x [any-type!]] [case [
		none? get/any 'x [""]

  any-string? get/any 'x [ajoin [{"} replace/all copy x {"} {""} {"}]]
		get/any 'x = #"^"" [{""""}]
		char? get/any 'x [ajoin [{"} x {"}]]
		scalar? get/any 'x [form x]
		date? get/any 'x [to-iso-date x]

  any [any-word? get/any 'x any-path? get/any 'x binary? get/any 'x] 
  [
			ajoin [{"} replace/all to-string :x {"} {""} {"}]
		]
		'else [throw-error 'script 'invalid-arg get/any 'x]
	]]
]


There is likely a faster way to do these. I have R3 variants of these 
too.
Henrik:
18-Dec-2011
BrianH, testing csv-tools.r now.

Is this a bug?:

>> to-iso-date 18-Dec-2011/14:57:11
** Script Error: Invalid path value: hour
** Where: ajoin
** Near: p0 date/hour 2 ":" p0
>> system/version
== 2.7.8.3.1
BrianH:
18-Dec-2011
As for that TO-ISO-DATE behavior, yes, it's a bug. Surprised I didn't 
know that you can't use /hour, /minute and /second on date! values 
with times in them in R2. It can be fixed by changing the date/hour 
to date/time/hour, etc. I'll update the script on REBOL.org.
BrianH:
18-Dec-2011
TO-ISO-DATE fixed on REBOL.org
BrianH:
20-Dec-2011
Be careful, if you don't quote string values then the character set 
of your values can't include cr, lf or your delimiter. It requires 
so many changes that it would be more efficient to add new formatter 
functions to the associated FUNCT/with object, then duplicate the 
code in TO-CSV that calls the formatter. Like this:

to-csv: funct/with [
	"Convert a block of values to a CSV-formatted line in a string."
	data [block!] "Block of values"

 /with "Specify field delimiter (preferably char, or length of 1)"
	delimiter [char! string! binary!] {Default ","}
	; Empty delimiter, " or CR or LF may lead to corrupt data
	/no-quote "Don't quote values (limits the characters supported)"
] [
	output: make block! 2 * length? data
	delimiter: either with [to-string delimiter] [","]
	either no-quote [
		unless empty? data [append output format-field-nq first+ data]

  foreach x data [append append output delimiter format-field-nq :x]
	] [
		unless empty? data [append output format-field first+ data]
		foreach x data [append append output delimiter format-field :x]
	]
	to-string output
] [
	format-field: func [x [any-type!] /local qr] [

  ; Parse rule to put double-quotes around a string, escaping any inside

  qr: [return [insert {"} any [change {"} {""} | skip] insert {"}]]
		case [
			none? :x [""]
			any-string? :x [parse copy x qr]
			:x = #"^(22)" [{""""}]
			char? :x [ajoin [{"} x {"}]]
			money? :x [find/tail form x "$"]
			scalar? :x [form x]
			date? :x [to-iso-date x]

   any [any-word? :x binary? :x any-path? :x] [parse to-string :x qr]
			'else [cause-error 'script 'expect-set reduce [

    [any-string! any-word! any-path! binary! scalar! date!] type? :x
			]]
		]
	]
	format-field-nq: func [x [any-type!]] [
		case [
			none? :x [""]
			any-string? :x [x]
			money? :x [find/tail form x "$"]
			scalar? :x [form x]
			date? :x [to-iso-date x]
			any [any-word? :x binary? :x any-path? :x] [to-string :x]
			'else [cause-error 'script 'expect-set reduce [

    [any-string! any-word! any-path! binary! scalar! date!] type? :x
			]]
		]
	]
]


If you want to add error checking to make sure the data won't be 
corrupted, you'll have to pass in the delimiter to format-field-nq 
and trigger an error if it, cr or lf are found in the field data.
Group: !Readmail ... a Rebol mail client [web-public]
Fabrice:
20-May-2005
Received: from web26108.mail.ukl.yahoo.com ([217.12.10.232])

        by mail.prosygma-asp.com (Merak 7.5.2) with SMTP id 1TI26716
        for <[me-:-you-:-com]>; Tue, 26 Apr 2005 04:58:31 +0200

Received: (qmail 67900 invoked by uid 60001); 26 Apr 2005 02:58:30 
-0000

Message-ID: <[20050426025830-:-67898-:-qmail-:-web26108-:-mail-:-ukl-:-yahoo-:-com]>

Received: from [81.248.68.164] by web26108.mail.ukl.yahoo.com via 
HTTP; Tue, 26 Apr 2005 04:58:29 CEST
Date: Tue, 26 Apr 2005 04:58:29 +0200 (CEST)
From: Rodrigue <[you-:-me-:-com]>
Subject: Re: Erreur lors de l'enregistrement d'une news
To: Admin Rebol <[me-:-you-:-com]>
In-Reply-To: 6667
MIME-Version: 1.0

Content-Type: multipart/alternative; boundary="0-370637848-1114484309=:67141"
Content-Transfer-Encoding: 8bit
X-Antivirus: avast! (VPS 0517-0, 25/04/2005), Inbound message
X-Antivirus-Status: Clean

--0-370637848-1114484309=:67141
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Salut Fabrice,
 
Peux tu me redire sous quel format je dois envoyer les photos

Rodrigue

Admin Rebol <[me-:-you-:-com]> wrote:
Bonjour Rodrigue,

>Salut Fabrice,

>contrairement à ce que je t'expliquais hier soir, les news ne s'enregistrent 
pas.
>voilà le message d'erreur : 

Peux-tu m'envoyer ce que tu veux mettre en ligne par @ ?

Je vérifierais directement avec tes données car il n'y a pas de problème 
de mon côté pour ajouter les news.

Merci.

-- 
Fabrice

		
---------------------------------

 Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour 
 vos mails !
Créez votre Yahoo! Mail
--0-370637848-1114484309=:67141
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<DIV>Salut Fabrice,</DIV>
<DIV>&nbsp;</DIV>

<DIV>Peux tu me redire sous quel format je dois envoyer les photos<BR></DIV>
<DIV>Rodrigue</DIV>

<DIV><BR><B><I>Admin Rebol &lt;[me-:-you-:-com]&gt;</I></B> wrote:</DIV>

<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; 
BORDER-LEFT: #1010ff 2px solid">Bonjour Rodrigue,<BR><BR>&gt;Salut 
Fabrice,<BR>&gt;contrairement à ce que je t'expliquais hier soir, 
les news ne s'enregistrent pas.<BR>&gt;voilà le message d'erreur 
: <BR><BR>Peux-tu m'envoyer ce que tu veux mettre en ligne par @ 
?<BR>Je vérifierais directement avec tes données car il n'y a pas 
de problème de mon côté pour ajouter les news.<BR><BR>Merci.<BR><BR>-- 
<BR>Fabrice<BR></BLOCKQUOTE><p>
		<hr size=1> 

Découvrez le nouveau Yahoo! Mail : <font color="red">250 Mo d'espace</font> 
de stockage pour vos mails !<br><a href="http://fr.rd.yahoo.com/mail/taglines/*http://us.rd.yahoo.com/evt=25917/*http://us.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_250/default/*http://fr.promotions.yahoo.com/mail/creer28.html">Créez 
votre Yahoo! Mail</a>


--0-370637848-1114484309=:67141--
Group: SQLite ... C library embeddable DB [web-public].
sqlab:
21-Mar-2006
YYYYMMDD is the short form of the iso date, 
otherwise it should be YYYY-MM-DD, if I remember.
Group: Core ... Discuss core issues [web-public]
james_nak:
12-Mar-2011
I think this is a Graham question. I've been trying to communicate 
with this video encoder. It uses .xml and .cgi files to talk to it:
tmp: http-tools http://192.168.1.62/user/GetTTLStatus.xml[]
and this works fine.


The problem is with he .cgi files. They aren't POST files but they 
only return 

 a: http-tools http://192.168.1.62/user/StorageMediaFiles.cgi[] probe 
 a
make object! [
    HTTP-Response: "<?xml version='1.0' encoding='ISO-8859-1' ?>"
    Date: none
    Server: none
    Last-Modified: none
    Accept-Ranges: none
    Content-Encoding: none
    Content-Type: none
    Content-Length: none
    Location: none
    Expires: none
    Referer: none
    Connection: none
    Set-Cookie: none
]
When you place the url in a browser it works as expected. 
Any ideas on how to get this to work?
james_nak:
12-Mar-2011
And you're right, there is probably something else going on. I am 
at least getting part of the message. A successful .xml call looks 
like this:

a: http-tools http://192.168.1.62/user/StorageEventMode.xml[] probe 
a
make object! [
    HTTP-Response: "HTTP/1.1 200 OK"
    Date: none
    Server: "Mango DSP - HTTP Server (v2.34)"
    Last-Modified: none
    Accept-Ranges: none
    Content-Encoding: none
    Content-Type: "text/xml"
    Content-Length: "270"
    Location: none
    Expires: none
    Referer: none
    Connection: none
    Set-Cookie: none
    Cache-Control: "no-store"
    content: {<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="StorageEventMode.xsl"?>
<StorageEventMode>
^-<RecOnNetworkFailure id="RecOnNetworkFailure" checked="true"/>
^-<PreEventBufferTime id="PreEventBufferTime" value="20"/>
</StorageEventMode>
}
]